package org.example.short_link.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.example.short_link.admin.remote.ShortLinkRemoteService;
import org.example.short_link.admin.remote.dto.req.ShortLinkCreateReqDTO;
import org.example.short_link.admin.remote.dto.req.ShortLinkPageReqDTO;
import org.example.short_link.admin.remote.dto.req.ShortLinkStatsReqDTO;
import org.example.short_link.admin.remote.dto.req.ShortLinkUpdateReqDTO;
import org.example.short_link.admin.remote.dto.resp.ShortLinkCreateRespDTO;
import org.example.short_link.admin.remote.dto.resp.ShortLinkPageRespDTO;
import org.example.short_link.admin.remote.dto.resp.ShortLinkStatsRespDTO;
import org.springframework.web.bind.annotation.*;
import org.example.short_link.admin.common.convention.result.Result;
import org.example.short_link.admin.common.convention.result.Results;

/**
 * 后管控制中台
 */
@RestController
public class ShortLinkController {

    // TODO : 后续重构为 SpringCould Field调用
    ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){

    };


    @GetMapping("/api/short-link/v1/admin/group/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(ShortLinkPageReqDTO requestParam){
        return shortLinkRemoteService.pageShortLink(requestParam);
    }


    @PostMapping("/api/short-link/v1/admin/group/create")
    public Result<ShortLinkCreateRespDTO> createShortLink(@RequestBody ShortLinkCreateReqDTO requestParam){
        return shortLinkRemoteService.createShortLink(requestParam);
    }

    @PostMapping("/api/short-link/v1/admin/group/update")
    public Result<Void> updateShortLink(@RequestBody ShortLinkUpdateReqDTO requestParam){
        shortLinkRemoteService.updateShortLink(requestParam);
        return Results.success();
    }


    @GetMapping("/api/short-link/v1/admin/stats")
    public Result<ShortLinkStatsRespDTO> oneShortLinkStats(@RequestBody ShortLinkStatsReqDTO requestParam){

        return Results.success(shortLinkRemoteService.oneShortLinkStats(requestParam));

    }













}
